package cn.itcast.jd.service.impl;

import cn.itcast.jd.dao.ItemDAO;
import cn.itcast.jd.pojo.Item;
import cn.itcast.jd.service.ItemService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class ItemServiceImpl implements ItemService {


    @Autowired
    private ItemDAO itemDAO;


    @Override
    @Transactional //开启事物提交事物必加
    public void save(Item item) {
        this.itemDAO.save(item);
    }

    @Override
    public List<Item> findAll(Item item) {

//        声明查找条件

        Example<Item> example = Example.of(item);
        List<Item> list = this.itemDAO.findAll(example);

        return list;
    }
}
